package com.app.TCES.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.app.TCES.domain.Class;
import com.app.TCES.domain.ClassSet;
import com.app.TCES.domain.Department;

@Mapper
public interface ClassMapper {

	@Select("select c.classId,d.deptName,c.className from class c,department d where c.deptId = d.deptId ")
	List<ClassSet> getClassSet();

	@Delete("delete from class where classId = #{classId}")
	void deleteClass(@Param("classId")Integer classId);

	@Select("select count(*) from class where classId = #{classes.classId}")
	int selectClass(@Param("classes")Class classes);

	@Select("select count(*) from class where className = #{classes.className}")
	int SelectClassName(@Param("classes")Class classes);
	
	@Insert("insert into class(classId,className,deptId) values(#{classes.classId},#{classes.className},#{classes.deptId})")
	void insertClass(@Param("classes")Class classes);

	@Update("update class set deptId = #{classes.deptId} where classId = #{classes.classId}")
	void updateClass(@Param("classes")Class classes);

	@Select("select * from department")
	List<Department> getDepartments();

	@Select("select c.classId,d.deptName,c.className from class c,department d where c.deptId = d.deptId and d.deptName=#{deptName}")
	List<Class> getClassList(@Param("deptName")String deptName);

	
}
